Calculate Chlorophyll Concentration
Equations for Dinos from Jeffrey and Humphrey 1975 in 100% acetone
Chla = 11.43 * A663 - 0.64 * A630 Chlc2 = 27.09 * A630 - 3.63 * A663
##Subtract Background A750 from A630 and A663
Chl$A630.c<-Chl$A630-Chl$A750
Chl$A663.c<-Chl$A663-Chl$A750
##Divide by Pathlength (0.5cm pathlength for 175ul sample in UVStar Plate)
Chl$A630.c<-c(Chl$A630.c/0.5)
Chl$A663.c<-c(Chl$A663.c/0.5)
##Calculate Chl-a and Chl-c2 in ug/ml
Chl$Chl.a_ug.ml<-11.43*Chl$A663.c- 0.64*Chl$A630.c
Chl$Chl.c2_ug.ml <- 27.09*Chl$A630.c - 3.63*Chl$A663.c
##Merge with Sample Data to Calculate Chlorophyll per Surface Area
#Merges by Random Number (RandN) column
#Adds necessary Slurry Volume (Vol_ml) and Surface Area (SA_cm2) columns
Chl<-merge(Chl, SampData, all=TRUE)
##Calculate Total Chlorophyll-a and c2 (ug)
Chl$Chl.a_ug<-Chl$Chl.a_ug.ml*Chl$Vol_ml
Chl$Chl.c2_ug<-Chl$Chl.c2_ug.ml*Chl$Vol_ml
##Calculate Chlorophyll-a and c2 per Surface Area (ug/cm^2)
Chl$Chl.a_ug.cm2<-Chl$Chl.a_ug/Chl$SA_cm2
Chl$Chl.c2_ug.cm2<-Chl$Chl.c2_ug/Chl$SA_cm2
##Initial Visual Check
ggplot(Chl, aes(x=Set, y=Chl.a_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
theme(axis.text.x = element_text(angle = 90))

ggplot(Chl, aes(x=Set, y=Chl.c2_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
theme(axis.text.x = element_text(angle = 90))

##Set Negative Values to Zero
Chl$Chl.a_ug.cm2[(which(Chl$Chl.a_ug.cm2<0))]<-0
Chl$Chl.c2_ug.cm2[(which(Chl$Chl.c2_ug.cm2<0))]<-0
##Add Chlorophyll-a and c2 for Total Chlorophyll per Surface Area (ug/cm^2)
Chl$Chl_ug.cm2<-Chl$Chl.a_ug.cm2+Chl$Chl.c2_ug.cm2
##Visual Check
ggplot(Chl, aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
theme(axis.text.x = element_text(angle = 90))

Check for Outliers
Check for Outliers by Treatment and Timepoint, grouped by sample set.
Removing clear outlier samples and outliers of technical replicates
before averaging across technical repliates.
Main
##Subset Main Corals
Chl.M<-subset(Chl, Treat=="M")
#TP1
ggplot(subset(Chl.M, TimeP=="TP1"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,2.5)+
theme(axis.text.x = element_text(angle = 90))

#TP2
ggplot(subset(Chl.M, TimeP=="TP2"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,4.5)+
theme(axis.text.x = element_text(angle = 90))

#TP3
ggplot(subset(Chl.M, TimeP=="TP3"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,4.5)+
theme(axis.text.x = element_text(angle = 90))

#TP4
ggplot(subset(Chl.M, TimeP=="TP4"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,7.5)+
theme(axis.text.x = element_text(angle = 90))

Chl.M$RandN[which(Chl.M$TimeP=="TP4" & Chl.M$Chl_ug.cm2>6)] #"222" "222" "222" #Also outlier for Protein and Biomass
[1] "222" "222" "222"
##Remove Outliers
Chl.M.o<-Chl.M[-c(which(Chl.M$TimeP=="TP4" & Chl.M$Chl_ug.cm2>6)),]
Control
##Subset Control Treatment in Thermal Tolerance Assay
Chl.C<-subset(Chl, Treat=="C")
#IN
ggplot(subset(Chl.C, TimeP=="IN"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,2.5)+
theme(axis.text.x = element_text(angle = 90))

Chl.C$RandN[which(Chl.C$TimeP=="IN" & Chl.C$Chl_ug.cm2<0.25)] #"W2_45"
[1] "W2_45"
#TP1
ggplot(subset(Chl.C, TimeP=="TP1"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,2.5)+
theme(axis.text.x = element_text(angle = 90))

#TP2
ggplot(subset(Chl.C, TimeP=="TP2"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,2.5)+
theme(axis.text.x = element_text(angle = 90))

#TP3
ggplot(subset(Chl.C, TimeP=="TP3"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,3.5)+
theme(axis.text.x = element_text(angle = 90))

Chl.C$RandN[which(Chl.C$TimeP=="TP3" & Chl.C$Chl_ug.cm2>2.5)] #"M8_33" "M8_33" "M8_33"
[1] "M8_33" "M8_33" "M8_33"
#TP4
ggplot(subset(Chl.C, TimeP=="TP4"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,4)+
theme(axis.text.x = element_text(angle = 90))

##Remove Outliers
Chl.C.o<-Chl.C[-c(which((Chl.C$TimeP=="IN" & Chl.C$Chl_ug.cm2<0.25)|
(Chl.C$TimeP=="TP3" & Chl.C$Chl_ug.cm2>2.5))),]
Heated
##Subset Heated Treatment in Thermal Tolerance Assay
Chl.H<-subset(Chl, Treat=="H")
#IN
ggplot(subset(Chl.H, TimeP=="IN"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,1)+
theme(axis.text.x = element_text(angle = 90))

Chl.H$RandN[which(Chl.H$TimeP=="IN" & Chl.H$Chl_ug.cm2>0.75)] #"W2_88" "W2_88" "W2_88"
[1] "W2_88" "W2_88" "W2_88"
#TP1
ggplot(subset(Chl.H, TimeP=="TP1"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,1)+
theme(axis.text.x = element_text(angle = 90))

#TP2
ggplot(subset(Chl.H, TimeP=="TP2"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,1)+
theme(axis.text.x = element_text(angle = 90))

#TP3
ggplot(subset(Chl.H, TimeP=="TP3"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,2)+
theme(axis.text.x = element_text(angle = 90))

Chl.H$RandN[which(Chl.H$TimeP=="TP3" & Chl.H$Chl_ug.cm2>1.5 & Chl.H$Genotype=="AC10")] #"M8_11" "M8_11"
[1] "M8_11" "M8_11"
#TP4
ggplot(subset(Chl.H, TimeP=="TP4"), aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
ylim(0,1)+
theme(axis.text.x = element_text(angle = 90))

Chl.H$RandN[which(Chl.H$TimeP=="TP4" & Chl.H$Chl_ug.cm2>0.5)] #"M12_63" "M12_63" "M12_63"
[1] "M12_63" "M12_63" "M12_63"
##Remove Outliers
Chl.H.o<-Chl.H[-c(which((Chl.H$TimeP=="IN" & Chl.H$Chl_ug.cm2>0.75) |
(Chl.H$TimeP=="TP3" & Chl.H$Chl_ug.cm2>1.5 & Chl.H$Genotype=="AC10") |
(Chl.H$TimeP=="TP4" & Chl.H$Chl_ug.cm2>0.50))),]
Add Chlorophyll to Main and Thermal Datasets
##Recombine Cleaned Chlorophyll dataframes
Chl.o<-rbind(Chl.M.o, Chl.C.o, Chl.H.o)
ggplot(Chl.o, aes(x=Set, y=Chl_ug.cm2)) +
geom_boxplot(alpha=0.5, shape=2, outlier.shape = NA)+
geom_jitter(shape=16, position=position_jitter(0.1))+
theme(axis.text.x = element_text(angle = 90))

##Average Across Replicate Readings ("Rep" column: A, B, C)
names(Chl.o)
[1] "RandN" "Row" "Column" "Well" "Plate" "Rep"
[7] "A630" "A663" "A750" "A630.c" "A663.c" "Chl.a_ug.ml"
[13] "Chl.c2_ug.ml" "ID" "TimeP" "Site" "Genotype" "Treat"
[19] "Treatment" "Orig" "Origin" "Vol_ml" "Wax.I_g" "Wax.F_g"
[25] "Set" "Site.Orig" "Wax.D_g" "SA_cm2" "Chl.a_ug" "Chl.c2_ug"
[31] "Chl.a_ug.cm2" "Chl.c2_ug.cm2" "Chl_ug.cm2"
Chl.a<-aggregate(Chl.o$Chl_ug.cm2, list(Chl.o$RandN, Chl.o$ID), mean)
names(Chl.a)<-c("RandN", "ID", "Chl_ug.cm2")
##Add Total Chlorophyll to Main Coral Data and Thermal Tolerance Data
##Merge Averaged Chlorophyll Data with Coral Main Data
#Merges by Random Number (RandN) and ID columns
#Retains all Main samples
names(Chl.a)
[1] "RandN" "ID" "Chl_ug.cm2"
CoralData<-merge(CoralData, Chl.a, all.x=TRUE, all.y=FALSE)
##Merge Averaged Chlorophyll Data with Thermal Tolerance Data
#Merges by Random Number (RandN) and ID columns
#Retains all Thermal Tolerance Assay samples
#Retains RandN, ID, TimeP, Site, Genotype, Treat, Treatment, Orig, Origin, Set, and SA_cm2 from Corals_Therm
names(Corals_Therm)
[1] "RandN" "ID" "TimeP" "Site" "Genotype" "Treat" "Treatment" "Orig"
[9] "Origin" "Vol_ml" "Wax.I_g" "Wax.F_g" "Set" "Site.Orig" "Wax.D_g" "SA_cm2"
ThermData<-merge(Corals_Therm[,c(1:9, 13:14, 16)], Chl.a, all.x=TRUE, all.y=FALSE)